<?php //pack11class

class ObjectsList extends Module {

        public $comments="";
        public $navigation="";
        public $traceEnabled=true;

	public function setup() {
        $objects=ObjectsManager::getObjects();
        if(!$objects) return false;

        $form=new Form;
        $form->setID("Objects");
        $data=new HiddenInput;
        $data->setID("ObjectsList");
        $data->setName("objects");
        $obs=array();
        foreach($objects as $object) array_push($obs,$object->id);
        $data->setBody(implode(",", $obs));
        $form->addChild($data);
        $this->addChild($form);

        $sortable=ObjectsManager::$sortable;
        $sortableLabels=array();
        foreach($sortable as $property) {
            array_push($sortableLabels,$property->label);
        }

        $this->addChild(new ObjectsListHeader);
        foreach(ObjectsManager::$objects as $object) {
            $item=new ObjectsListItem;
            $item->object=$object;
            $this->addChild($item);
        }

       $this->navigation=Template::html(new ObjectsListNavigation);
        
        $comments=ObjectsListComments::getComments();
        //print_r($comments);

        if(count($comments)>0) {
            $commentsSet=array();
            $stars="";
            foreach($comments as $comment) {
                if(!array_key_exists($comment->type, $commentsSet)) {
                    $stars.=ObjectsListComments::STAR;
                    $comment->stars=$stars;
                    $this->comments.=Template::html($comment);
                    $commentsSet[$comment->type]=$comment;
                }
            }
        }
        //$this->setBody(implode(", ",$sortableLabels));
    }

}
?>
